/*	Interactive Gravitational Simulator
	Project: IGS Core
	File: Body.h
	Author: Mike Bantegui <mbante2@gmail.com>, Hofstra University 
	Copyright (C) 2012 - 2013 Mike Bantegui

	This file is part of the IGS software package for simulating
	the N-Body problem in real-time. This was developed as part
	of a departmental honors thesis project at Hofstra University
	in the Spring 2012 semester.

	IGS is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	IGS is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef IGS_BODY_H
#define IGS_BODY_H

#include "Graviton.h"

namespace IGS
{

// Represents a body within the N-Body simulation
struct Body : public Graviton
{
	// The square of the time to collision with another body
	double CollisionTimescaleSq;
	// The next time for the body
	double NextTime;
	// Starting point in phase space
	WorldPoint Start;
	// Ending point in phase space
	WorldPoint End;

	Body();
	Body(const double mass, const Vector &position, const Vector &velocity);
	~Body();

	ViewNode *AsReadOnly() const;

	void CheckTimescale(const double timescaleSquared);

	void Pairwise(Body &other, const double softening);
	void Direct(Body &other, const double softening) const;

	double MultipolePotential(const Vector &dr, const double r1, const double r2) const;
	void AddMultipole(Node &branch) const;

	void EndStep();

	friend std::ostream &operator<<(std::ostream &os, const Body &body);
	friend std::istream &operator>>(std::istream &is, Body &body);
};

}

#endif